<!DOCTYPE html>
<html xmlns:th="www.thymeleaf.org">
<head th:replace="index::head"></head>
<body>
<div class="bodymain">

    <div th:replace="index::.layui-header"></div>
    <div th:replace="index::.main-nav"></div>

    <link rel="stylesheet" type="text/css" href="bbs/images/css.css">
    <div class="layui-main">
        <div style="clear:both">
        </div>
        <div style="height:30px; display:block; clear:both"></div>
        <div class="layui-box fdc-body">
            <div style="width: 500px; margin: auto">
                <div id="tree"></div>
                <script>
                    var json = '[[${T(com.example.springboot.util.Utils).toJson(menus)}]]';
                    // 替换所有的 &quot; ==> "
                    json = json.replace(/&quot;/g,'"');
                    var data = JSON.parse(json);

                    //渲染
                    var inst1 = layui.tree.render({
                        elem: '#tree'  //绑定元素
                        ,data: data
                        ,edit: ['add', 'update', 'del']
                        ,operate: function(obj){
                            // obj.elem; //得到当前节点元素  jQuery 对象 ( jquery 对 html 对象的封装)
                            console.info(obj)
                            if(obj.type == 'del'){
                                axios.get("delMenu?id=" + obj.data.id).then(res=>{
                                    layer.alert(res.data.msg);
                                })
                            } else if(obj.type == 'update'){
                                axios.get("modMenu?id=" + obj.data.id + "&name=" + obj.data.title).then(res=>{
                                    layer.alert(res.data.msg);
                                })
                            } else if(obj.type == 'add'){

                            }
                        }
                    });
                </script>
            </div>
        </div>
        <div class="line_10"></div>
    </div>

    <!-- 引入页脚-->
    <div th:replace="index::.footer"></div>
</div>
</body>
</html>